package com.pig4cloud.pig.village.rules;

import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.util.List;

/**
 * 数据汇总
 *
 * @author limbray.li
 * @date 2021/7/27
 */
@Data
@AllArgsConstructor
@NoArgsConstructor
public class DataCollect {
	//(welfareId+raise+timeDimension+groupDimension+year)
	private Long welfareId;
	private Integer raise;
	private Integer timeDimension;
	//0：人，1：户，2：队
	private Integer groupDimension;
	private Integer year;
	@ApiModelProperty("人")
	private List<VillagerData> villagers;
	@ApiModelProperty("户")
	private List<FamilyData> familys;
	@ApiModelProperty("队")
	private List<TeamData> teams;

	public DataCollect(List<VillagerData> villagers, List<FamilyData> familys, List<TeamData> teams) {
		this.villagers = villagers;
		this.familys = familys;
		this.teams = teams;
	}

	public String getRuleCode() {
		if (groupDimension != null) {
			return welfareId + "-" + raise + "-" + timeDimension + "-" + groupDimension;
		}
		return welfareId + "-" + raise + "-" + timeDimension + "-" + 0;
	}

	public String getRuleCodeFamily() {
		if (groupDimension != null) {
			return null;
		}
		return welfareId + "-" + raise + "-" + timeDimension + "-" + 1;
	}

	public String getRuleCodeTeam() {
		if (groupDimension != null) {
			return null;
		}
		return welfareId + "-" + raise + "-" + timeDimension + "-" + 2;
	}
}
